package com.wanmait.houlang.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.houlang.mapper.ManagerMapper;
import com.wanmait.houlang.pojo.DTO;
import com.wanmait.houlang.pojo.Manager;
import com.wanmait.houlang.service.ManagerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class ManagerServiceImpl implements ManagerService {
    @Resource
    private ManagerMapper managerMapper;
    @Override
    public void insert(Manager object) {
        managerMapper.insert(object);
    }

    @Override
    public void delete(Integer id) {

    }

    @Override
    public void delete(String ids) {

    }
//更新管理员的最后登录时间以及登录ip
    @Override
    public void update(Manager object) {
        managerMapper.updateInfo(object);
    }

    @Override
    public Manager findById(Integer id) {
        return null;
    }

    @Override
    public List<Manager> findAll() {
        return null;
    }

    @Override
    public PageInfo<Manager> findAll(int pageNum, int pageSize, Manager object) {

        return null;
    }

    @Override
    public Manager login(Manager manager) {
        Manager loginManager=managerMapper.findByNameAndPass(manager);
        return loginManager;
    }

    @Override
    public Manager telLogin(DTO dto) {
        Manager manager=managerMapper.findByTel(dto);
        return manager;
    }

    @Override
    public PageInfo<Manager> findAll(int pageNum, int pageSize, DTO dto) {
        PageHelper.startPage(pageNum,pageSize);
        List<Manager> managers=managerMapper.findAll(dto);
        PageInfo<Manager> managerPageInfo = new PageInfo<>(managers);
        return managerPageInfo;
    }

    @Override
    public void updateManagerInfo(Manager manager) {
        managerMapper.updateManagerInfo(manager);
    }

    @Override
    public void updateStatus(Integer managerId) {
        managerMapper.updateStatus(managerId);
    }
}
